var layer;


$(function() {
	layui.use('layer', function() {
		layer = layui.layer;
	});

	getMoney();

})

function getMoney() {
	$.ajax({
		type: "get",
		url: "http://localhost:8810/loan/app/index/getByMoney",
		dataType: "json",
		async: false,
		//这里是重点
		beforeSend: setHeader,
		success: function(data) {
			var entity = data.entity;
			$("#applyMoney").text(parseFloatValue(entity.applyMoney));
			$("#manageMoney").text(parseFloatValue(entity.manageMoney));
			$("#examineMoney").text(parseFloatValue(entity.examineMoney));
			$("#serviceMoney").text(parseFloatValue(entity.serviceMoney));
			$("#realMoney").text(parseFloatValue(entity.applyMoney - entity.manageMoney - entity.examineMoney - entity.serviceMoney));
			$("#paymentDate").text(getDay(entity.cycle - 1));
		},
		error: function(error) {
			layer.msg(error.message);
		}
	})
}

function submit(){
	$.ajax({
		url: 'http://localhost:8810/loan/app/apply/saveApply',
		type: 'post',
		contentType: 'application/json',
		beforeSend: setHeader,
		success: function(data) {
			if (data.code == 0) {
				loading = false;
				window.location.href = "grzx4.html";
			} else {
				layer.msg(data.msg);
				loading = false;
			}
		}
	});
}


function parseFloatValue(num) {
	// num = num.replace(/./g, "");
	// var value = parseFloat(Number(num)).toLocaleString();
	// return value;
	return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
